﻿
using Domain.Model.Commons.Atrributes;
using System.Text;
namespace Domain.Model.Commons
{
    /// <summary>
    /// 主要实体Model的抽象基类，实现了两个接口：IDeleteable, IVersionable
    /// </summary>
    public abstract class BaseEntity : AbstractEntity, IDeleteable, IVersionable
    {
        [Version("Version")]
        public virtual int Version { get; set; }

        [Property("deleted_flag")]
        public virtual bool IsDeleted { get; set; }

        public virtual void MarkedAsDeleted()
        {
            IsDeleted = true;
        }

        public virtual void MarkedAsAvailable()
        {
            IsDeleted = false;
        }

        public override string ToString()
        {
            return new StringBuilder(base.ToString()).Append("\tVersion : " + Version).Append("\tIsDeleted : " + IsDeleted).ToString();
        }
    }
}
